home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / swingall.jar / javax / swing / AppContext.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-07-15  |  2.0 KB  |  74 lines

  1. package javax.swing;
  2.  
  3. import java.util.Hashtable;
  4.  
  5. final class AppContext {
  6.    private static Hashtable security2appContexts = null;
  7.    private static Object nullSecurityContext = new Object();
  8.    private static AppContext systemAppContext;
  9.    private final Hashtable table = new Hashtable(2);
  10.    private static Object lastKey;
  11.    private static Object lastValue;
  12.  
  13.    static {
  14.       systemAppContext = new AppContext(nullSecurityContext);
  15.    }
  16.  
  17.    private AppContext(Object var1) {
  18.       if (var1 != nullSecurityContext) {
  19.          if (security2appContexts == null) {
  20.             security2appContexts = new Hashtable(2, 0.2F);
  21.          }
  22.  
  23.          security2appContexts.put(var1, this);
  24.       }
  25.  
  26.    }
  27.  
  28.    public synchronized Object get(Object var1) {
  29.       if (var1 != lastKey || lastValue == null) {
  30.          lastValue = this.table.get(var1);
  31.          lastKey = var1;
  32.       }
  33.  
  34.       return lastValue;
  35.    }
  36.  
  37.    public static AppContext getAppContext() {
  38.       Object var0 = nullSecurityContext;
  39.       if (var0 == nullSecurityContext) {
  40.          return systemAppContext;
  41.       } else {
  42.          AppContext var1 = (AppContext)security2appContexts.get(var0);
  43.          if (var1 == null) {
  44.             var1 = new AppContext(var0);
  45.             security2appContexts.put(var0, var1);
  46.          }
  47.  
  48.          return var1;
  49.       }
  50.    }
  51.  
  52.    public synchronized Object put(Object var1, Object var2) {
  53.       return this.table.put(var1, var2);
  54.    }
  55.  
  56.    public synchronized Object remove(Object var1) {
  57.       return this.table.remove(var1);
  58.    }
  59.  
  60.    public String toString() {
  61.       Object var1 = nullSecurityContext;
  62.       SecurityManager var2 = System.getSecurityManager();
  63.       if (var2 != null) {
  64.          Object var3 = System.getSecurityManager().getSecurityContext();
  65.          if (var3 != null) {
  66.             var1 = var3;
  67.          }
  68.       }
  69.  
  70.       String var4 = var1.equals(nullSecurityContext) ? "null" : var1.toString();
  71.       return this.getClass().getName() + "[SecurityContext=" + var4 + "]";
  72.    }
  73. }
  74.